package com.hp.idempotence.v4.service;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hp.idempotence.common.Result;
import com.hp.idempotence.v4.repository.UserRepository;

@Service
public class UserService {
	
	@Autowired
	private UserRepository userRepository;

	@Transactional
	public Result updateUser(String realname, long id, int version) throws Exception {
		
		int rows = userRepository.updateUser(realname, id, version);
		
		if(rows<=0){
			throw new InterruptedException("数据不匹配禁止更新");
		}
		
		return Result.success("操作成功!");
	}

}
